from tkinter import *
import tkinter as tk
import chem_module as ch

element_name = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds']
element_ar = [1, 4, 7, 9, 11, 12, 14, 16, 19, 20, 23, 24, 27, 28, 31, 32, 35.5, 40, 39, 40, 45, 48, 51, 52, 55, 56, 59, 59, 64, 65, 70, 73, 75, 79, 80, 84, 85, 88, 89, 91, 93, 96, 99, 101, 103, 106, 108, 112, 115, 119, 122, 128, 127, 131, 133, 137, 139, 140, 141, 144, 145, 150, 152, 157, 159, 162.5, 165, 167, 169, 173, 175, 178, 181, 184, 186, 190, 192, 195, 197, 201, 204, 207, 209, 209, 210, 222, 223, 226, 227, 232, 231, 238, 237, 244, 243, 247, 247, 251, 254, 257, 258, 259, 260, 261, 262, 263, 262, 265, 266, 269]

window = tk.Tk()
window.title("PyChem")

def chem():
	num = int(txtnum.get())
	name = element_name[num - 1]
	N = element_ar[num] - num
	group = ch.group_det(num)
	period = ch.period_det(num)
	row = ch.row_det(num)
	e_formula = ch.e_formula(group, period, row, num)

	data = tk.Toplevel(window)
	data.title("Данные о элементе " + name)

	lbl_name1 = Label(data, text="Имя элемента: ")
	lbl_name2 = Label(data, text=name)
	lbl_e1 = Label(data, text="Количество электронов: ")
	lbl_e2 = Label(data, text=num)
	lbl_p1 = Label(data, text="Количество протонов: ")
	lbl_p2 = Label(data, text=num)
	lbl_ar1 = Label(data, text="Относительная атомная масса: ")
	lbl_ar2 = Label(data, text=element_ar[num - 1])
	lbl_n1 = Label(data, text="Количество нейтронов: ")
	lbl_n2 = Label(data, text=N)
	lbl_group1 = Label(data, text="Номер группы: ")
	lbl_group2 = Label(data, text=group)
	lbl_period1 = Label(data, text="Номер периода: ")
	lbl_period2 = Label(data, text=period)
	lbl_e_formula1 = Label(data, text="Электронная формула: ")
	lbl_e_formula2 = Label(data, text=e_formula)

	lbl_name1.grid(column=0,row=0)
	lbl_name2.grid(column=1,row=0)
	lbl_e1.grid(column=0,row=1)
	lbl_e2.grid(column=1,row=1)
	lbl_p1.grid(column=0,row=2)
	lbl_p2.grid(column=1,row=2)
	lbl_n1.grid(column=0,row=3)
	lbl_n2.grid(column=1,row=3)
	lbl_ar2.grid(column=1,row=4)
	lbl_ar1.grid(column=0,row=4)
	lbl_group1.grid(column=0,row=5)
	lbl_group2.grid(column=1,row=5)
	lbl_period1.grid(column=0,row=6)
	lbl_period2.grid(column=1,row=6)
	lbl_e_formula1.grid(column=0,row=7)
	lbl_e_formula2.grid(column=1,row=7)

lblnum = Label(text="Введите номер элемента: ")
txtnum = Entry(width=5)
btn = Button(text="Найти", width=15, command=chem)

lblnum.grid(column=0,row=0)
txtnum.grid(column=1,row=0)
btn.grid(columnspan=2,row=1)

window.mainloop()